package com.centaline.androidsalesblog.rx.database;

import com.centaline.androidsalesblog.constants.AppConstant;
import com.centaline.androidsalesblog.model.databaseobject.FpHistoryDo;

import org.litepal.crud.DataSupport;

import rx.Observable;
import rx.Subscriber;

/**
 * 获取足迹数量
 * Created by guilin on 16/3/3.
 */
final class FpHistoryCountOnSubscribe implements Observable.OnSubscribe<Integer> {

    @Override
    public void call(Subscriber<? super Integer> subscriber) {
        if (!subscriber.isUnsubscribed()) {
            subscriber.onNext(DataSupport.where("cityCode = ?", AppConstant.CityCode).count(FpHistoryDo.class));
        }
        subscriber.onCompleted();
    }
}
